
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>输入变量 · 《Terraform入门教程》</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="大可不加冰">
        
        
    
    <link rel="stylesheet" href="gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-prism/prism-vsc-dark-plus.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-image-captions/image-captions.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="3.4.输出值.html" />
    
    
    <link rel="prev" href="3.2.配置语法.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="./">
            
                <a href="./">
            
                    
                        <b>1.1.</b>
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="1.Terraform初步体验.html">
            
                <a href="1.Terraform初步体验.html">
            
                    
                        <b>1.2.</b>
                    
                    Terraform 初步体验
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" >
            
                <span>
            
                    
                        <b>1.3.</b>
                    
                    Terraform基础概念
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="2.1.Terraform基础概念——Provider.html">
            
                <a href="2.1.Terraform基础概念——Provider.html">
            
                    
                        <b>1.3.1.</b>
                    
                    Provider
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="2.2.Terraform基础概念——状态管理.html">
            
                <a href="2.2.Terraform基础概念——状态管理.html">
            
                    
                        <b>1.3.2.</b>
                    
                    状态管理
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="3.Terraform代码的书写.html">
            
                <a href="3.Terraform代码的书写.html">
            
                    
                        <b>1.4.</b>
                    
                    Terraform 代码的书写
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="3.1.类型.html">
            
                <a href="3.1.类型.html">
            
                    
                        <b>1.4.1.</b>
                    
                    类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="3.2.配置语法.html">
            
                <a href="3.2.配置语法.html">
            
                    
                        <b>1.4.2.</b>
                    
                    配置语法
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.4.3" data-path="3.3.输入变量.html">
            
                <a href="3.3.输入变量.html">
            
                    
                        <b>1.4.3.</b>
                    
                    输入变量
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="3.4.输出值.html">
            
                <a href="3.4.输出值.html">
            
                    
                        <b>1.4.4.</b>
                    
                    输出值
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="3.5.局部值.html">
            
                <a href="3.5.局部值.html">
            
                    
                        <b>1.4.5.</b>
                    
                    局部值
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="3.6.资源.html">
            
                <a href="3.6.资源.html">
            
                    
                        <b>1.4.6.</b>
                    
                    资源
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7" data-path="3.7.数据源.html">
            
                <a href="3.7.数据源.html">
            
                    
                        <b>1.4.7.</b>
                    
                    数据源
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.8" data-path="3.8.表达式.html">
            
                <a href="3.8.表达式.html">
            
                    
                        <b>1.4.8.</b>
                    
                    表达式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.9" data-path="3.9.重载文件.html">
            
                <a href="3.9.重载文件.html">
            
                    
                        <b>1.4.9.</b>
                    
                    重载文件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.10" data-path="3.10.代码风格规范.html">
            
                <a href="3.10.代码风格规范.html">
            
                    
                        <b>1.4.10.</b>
                    
                    代码风格规范
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.11" data-path="3.11.checks.html">
            
                <a href="3.11.checks.html">
            
                    
                        <b>1.4.11.</b>
                    
                    Checks
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="4.Terraform模块.html">
            
                <a href="4.Terraform模块.html">
            
                    
                        <b>1.5.</b>
                    
                    Terraform 模块
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="4.1.创建模块.html">
            
                <a href="4.1.创建模块.html">
            
                    
                        <b>1.5.1.</b>
                    
                    创建模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="4.2.使用模块.html">
            
                <a href="4.2.使用模块.html">
            
                    
                        <b>1.5.2.</b>
                    
                    使用模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="4.3.模块元参数.html">
            
                <a href="4.3.模块元参数.html">
            
                    
                        <b>1.5.3.</b>
                    
                    模块元参数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="4.4.重构.html">
            
                <a href="4.4.重构.html">
            
                    
                        <b>1.5.4.</b>
                    
                    重构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="4.5.设计新模块的模式.html">
            
                <a href="4.5.设计新模块的模式.html">
            
                    
                        <b>1.5.5.</b>
                    
                    设计新模块的模式
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="5.Terraform命令行.html">
            
                <a href="5.Terraform命令行.html">
            
                    
                        <b>1.6.</b>
                    
                    Terraform 命令行
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="5.1.命令行配置文件.html">
            
                <a href="5.1.命令行配置文件.html">
            
                    
                        <b>1.6.1.</b>
                    
                    命令行配置文件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="5.2.环境变量.html">
            
                <a href="5.2.环境变量.html">
            
                    
                        <b>1.6.2.</b>
                    
                    环境变量
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="5.3.资源地址.html">
            
                <a href="5.3.资源地址.html">
            
                    
                        <b>1.6.3.</b>
                    
                    资源地址
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="5.4.apply.html">
            
                <a href="5.4.apply.html">
            
                    
                        <b>1.6.4.</b>
                    
                    apply
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="5.5.console.html">
            
                <a href="5.5.console.html">
            
                    
                        <b>1.6.5.</b>
                    
                    console
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6" data-path="5.6.destroy.html">
            
                <a href="5.6.destroy.html">
            
                    
                        <b>1.6.6.</b>
                    
                    destroy
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.7" data-path="5.7.fmt.html">
            
                <a href="5.7.fmt.html">
            
                    
                        <b>1.6.7.</b>
                    
                    fmt
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.8" data-path="5.8.force-unlock.html">
            
                <a href="5.8.force-unlock.html">
            
                    
                        <b>1.6.8.</b>
                    
                    force-unlock
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.9" data-path="5.9.get.html">
            
                <a href="5.9.get.html">
            
                    
                        <b>1.6.9.</b>
                    
                    get
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.10" data-path="5.10.graph.html">
            
                <a href="5.10.graph.html">
            
                    
                        <b>1.6.10.</b>
                    
                    graph
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.11" data-path="5.11.import.html">
            
                <a href="5.11.import.html">
            
                    
                        <b>1.6.11.</b>
                    
                    import
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.12" data-path="5.12.init.html">
            
                <a href="5.12.init.html">
            
                    
                        <b>1.6.12.</b>
                    
                    init
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.13" data-path="5.13.output.html">
            
                <a href="5.13.output.html">
            
                    
                        <b>1.6.13.</b>
                    
                    output
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.14" data-path="5.14.plan.html">
            
                <a href="5.14.plan.html">
            
                    
                        <b>1.6.14.</b>
                    
                    plan
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.15" data-path="5.15.providers.html">
            
                <a href="5.15.providers.html">
            
                    
                        <b>1.6.15.</b>
                    
                    providers
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.15.1" data-path="5.15.1.mirror.html">
            
                <a href="5.15.1.mirror.html">
            
                    
                        <b>1.6.15.1.</b>
                    
                    mirror
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.15.2" data-path="5.15.2.schema.html">
            
                <a href="5.15.2.schema.html">
            
                    
                        <b>1.6.15.2.</b>
                    
                    schema
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6.16" data-path="5.16.refresh.html">
            
                <a href="5.16.refresh.html">
            
                    
                        <b>1.6.16.</b>
                    
                    refresh
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.17" data-path="5.17.show.html">
            
                <a href="5.17.show.html">
            
                    
                        <b>1.6.17.</b>
                    
                    show
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.18" data-path="5.18.state.html">
            
                <a href="5.18.state.html">
            
                    
                        <b>1.6.18.</b>
                    
                    state
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.18.1" data-path="5.18.1.list.html">
            
                <a href="5.18.1.list.html">
            
                    
                        <b>1.6.18.1.</b>
                    
                    list
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.18.2" data-path="5.18.2.mv.html">
            
                <a href="5.18.2.mv.html">
            
                    
                        <b>1.6.18.2.</b>
                    
                    mv
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.18.3" data-path="5.18.3.pull.html">
            
                <a href="5.18.3.pull.html">
            
                    
                        <b>1.6.18.3.</b>
                    
                    pull
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.18.4" data-path="5.18.4.push.html">
            
                <a href="5.18.4.push.html">
            
                    
                        <b>1.6.18.4.</b>
                    
                    push
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.18.5" data-path="5.18.5.replace-provider.html">
            
                <a href="5.18.5.replace-provider.html">
            
                    
                        <b>1.6.18.5.</b>
                    
                    replace-provider
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.18.6" data-path="5.18.6.rm.html">
            
                <a href="5.18.6.rm.html">
            
                    
                        <b>1.6.18.6.</b>
                    
                    rm
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.18.7" data-path="5.18.7.show.html">
            
                <a href="5.18.7.show.html">
            
                    
                        <b>1.6.18.7.</b>
                    
                    show
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6.19" data-path="5.19.taint.html">
            
                <a href="5.19.taint.html">
            
                    
                        <b>1.6.19.</b>
                    
                    taint
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.20" data-path="5.20.validate.html">
            
                <a href="5.20.validate.html">
            
                    
                        <b>1.6.20.</b>
                    
                    validate
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.21" data-path="5.21.untaint.html">
            
                <a href="5.21.untaint.html">
            
                    
                        <b>1.6.21.</b>
                    
                    untaint
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.22" data-path="5.22.workspace.html">
            
                <a href="5.22.workspace.html">
            
                    
                        <b>1.6.22.</b>
                    
                    workspace
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.22.1" data-path="5.22.1.list.html">
            
                <a href="5.22.1.list.html">
            
                    
                        <b>1.6.22.1.</b>
                    
                    list
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.22.2" data-path="5.22.2.select.html">
            
                <a href="5.22.2.select.html">
            
                    
                        <b>1.6.22.2.</b>
                    
                    select
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.22.3" data-path="5.22.3.new.html">
            
                <a href="5.22.3.new.html">
            
                    
                        <b>1.6.22.3.</b>
                    
                    new
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.22.4" data-path="5.22.4.delete.html">
            
                <a href="5.22.4.delete.html">
            
                    
                        <b>1.6.22.4.</b>
                    
                    delete
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.22.5" data-path="5.22.5.show.html">
            
                <a href="5.22.5.show.html">
            
                    
                        <b>1.6.22.5.</b>
                    
                    show
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="6.test.html">
            
                <a href="6.test.html">
            
                    
                        <b>1.7.</b>
                    
                    Terraform Test
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="7.Aha——会心一击.html">
            
                <a href="7.Aha——会心一击.html">
            
                    
                        <b>1.8.</b>
                    
                    Aha——会心一击
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="7.1.有条件创建.html">
            
                <a href="7.1.有条件创建.html">
            
                    
                        <b>1.8.1.</b>
                    
                    有条件创建
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="7.2.依赖反转.html">
            
                <a href="7.2.依赖反转.html">
            
                    
                        <b>1.8.2.</b>
                    
                    依赖反转
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.3" data-path="7.3.多可用区分布.html">
            
                <a href="7.3.多可用区分布.html">
            
                    
                        <b>1.8.3.</b>
                    
                    多可用区分布
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.4" data-path="7.4.provisioner与user_data.html">
            
                <a href="7.4.provisioner与user_data.html">
            
                    
                        <b>1.8.4.</b>
                    
                    provisioner与user_data
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.5" data-path="7.5.destroy-provisioner中使用变量.html">
            
                <a href="7.5.destroy-provisioner中使用变量.html">
            
                    
                        <b>1.8.5.</b>
                    
                    destroy-provisioner中使用变量
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.6" data-path="7.6.利用null_resource的triggers触发其他资源更新.html">
            
                <a href="7.6.利用null_resource的triggers触发其他资源更新.html">
            
                    
                        <b>1.8.6.</b>
                    
                    利用null_resource的triggers触发其他资源更新
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.7" data-path="7.7.利用null_resource搭配replace_triggered_by更新无法读取的属性.html">
            
                <a href="7.7.利用null_resource搭配replace_triggered_by更新无法读取的属性.html">
            
                    
                        <b>1.8.7.</b>
                    
                    利用 null_resource 搭配 replace_triggered_by 更新无法从服务端读取内容的属性
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.8" data-path="7.8.创建资源的条件依赖另一个资源的输出时怎么办.html">
            
                <a href="7.8.创建资源的条件依赖另一个资源的输出时怎么办.html">
            
                    
                        <b>1.8.8.</b>
                    
                    创建资源的条件依赖另一个资源的输出时怎么办
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.9" data-path="7.9.利用create_before_destroy调整资源update执行的顺序.html">
            
                <a href="7.9.利用create_before_destroy调整资源update执行的顺序.html">
            
                    
                        <b>1.8.9.</b>
                    
                    利用 create_before_destroy 调整资源 Update 的执行顺序
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.10" data-path="7.10.terraform与自动化.html">
            
                <a href="7.10.terraform与自动化.html">
            
                    
                        <b>1.8.10.</b>
                    
                    Terraform 与自动化
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="8.CloudPosse最佳实践.html">
            
                <a href="8.CloudPosse最佳实践.html">
            
                    
                        <b>1.9.</b>
                    
                    来自CloudPosse的Terraform最佳实践
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="9.后记.html">
            
                <a href="9.后记.html">
            
                    
                        <b>1.10.</b>
                    
                    后记
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >输入变量</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><li><span class="title-icon "></span><a href="#&#x8F93;&#x5165;&#x53D8;&#x91CF;"><b>1.4.3.1. </b>&#x8F93;&#x5165;&#x53D8;&#x91CF;</a></li><ul><li><span class="title-icon "></span><a href="#&#x7C7B;&#x578B;-type"><b>1.4.3.1.1. </b>&#x7C7B;&#x578B; (type)</a></li><li><span class="title-icon "></span><a href="#&#x9ED8;&#x8BA4;&#x503C;-default"><b>1.4.3.1.2. </b>&#x9ED8;&#x8BA4;&#x503C; (default)</a></li><li><span class="title-icon "></span><a href="#&#x63CF;&#x8FF0;-description"><b>1.4.3.1.3. </b>&#x63CF;&#x8FF0; (description)</a></li><li><span class="title-icon "></span><a href="#&#x65AD;&#x8A00;-validation"><b>1.4.3.1.4. </b>&#x65AD;&#x8A00; (validation)</a></li><li><span class="title-icon "></span><a href="#&#x5728;&#x547D;&#x4EE4;&#x884C;&#x8F93;&#x51FA;&#x4E2D;&#x9690;&#x85CF;&#x503C;-sensitive"><b>1.4.3.1.5. </b>&#x5728;&#x547D;&#x4EE4;&#x884C;&#x8F93;&#x51FA;&#x4E2D;&#x9690;&#x85CF;&#x503C; (sensitive)</a></li><ul><li><span class="title-icon "></span><a href="#terraform-&#x53EF;&#x80FD;&#x66B4;&#x9732;&#x654F;&#x611F;&#x53D8;&#x91CF;&#x7684;&#x60C5;&#x51B5;"><b>1.4.3.1.5.1. </b>Terraform &#x53EF;&#x80FD;&#x66B4;&#x9732;&#x654F;&#x611F;&#x53D8;&#x91CF;&#x7684;&#x60C5;&#x51B5;</a></li></ul><li><span class="title-icon "></span><a href="#&#x7981;&#x6B62;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x4E3A;&#x7A7A;-nullable"><b>1.4.3.1.6. </b>&#x7981;&#x6B62;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x4E3A;&#x7A7A; (nullable)</a></li><li><span class="title-icon "></span><a href="#&#x5BF9;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x8D4B;&#x503C;"><b>1.4.3.1.7. </b>&#x5BF9;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x8D4B;&#x503C;</a></li><ul><li><span class="title-icon "></span><a href="#&#x547D;&#x4EE4;&#x884C;&#x53C2;&#x6570;"><b>1.4.3.1.7.1. </b>&#x547D;&#x4EE4;&#x884C;&#x53C2;&#x6570;</a></li><li><span class="title-icon "></span><a href="#&#x53C2;&#x6570;&#x6587;&#x4EF6;"><b>1.4.3.1.7.2. </b>&#x53C2;&#x6570;&#x6587;&#x4EF6;</a></li><li><span class="title-icon "></span><a href="#&#x73AF;&#x5883;&#x53D8;&#x91CF;"><b>1.4.3.1.7.3. </b>&#x73AF;&#x5883;&#x53D8;&#x91CF;</a></li><li><span class="title-icon "></span><a href="#&#x4EA4;&#x4E92;&#x754C;&#x9762;&#x4F20;&#x503C;"><b>1.4.3.1.7.4. </b>&#x4EA4;&#x4E92;&#x754C;&#x9762;&#x4F20;&#x503C;</a></li></ul><li><span class="title-icon "></span><a href="#&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x8D4B;&#x503C;&#x4F18;&#x5148;&#x7EA7;"><b>1.4.3.1.8. </b>&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x8D4B;&#x503C;&#x4F18;&#x5148;&#x7EA7;</a></li><ul><li><span class="title-icon "></span><a href="#terraform-&#x6D4B;&#x8BD5;&#x4E2D;&#x7684;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x503C;"><b>1.4.3.1.8.1. </b>Terraform &#x6D4B;&#x8BD5;&#x4E2D;&#x7684;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x503C;</a></li></ul><li><span class="title-icon "></span><a href="#&#x590D;&#x6742;&#x7C7B;&#x578B;&#x4F20;&#x503C;"><b>1.4.3.1.9. </b>&#x590D;&#x6742;&#x7C7B;&#x578B;&#x4F20;&#x503C;</a></li></ul></ul></div><a href="#&#x8F93;&#x5165;&#x53D8;&#x91CF;" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h1 id="&#x8F93;&#x5165;&#x53D8;&#x91CF;"><a name="&#x8F93;&#x5165;&#x53D8;&#x91CF;" class="anchor-navigation-ex-anchor" href="#&#x8F93;&#x5165;&#x53D8;&#x91CF;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.3.1. &#x8F93;&#x5165;&#x53D8;&#x91CF;</h1>
<p>&#x5728;&#x524D;&#x9762;&#x7684;&#x4F8B;&#x5B50;&#x4E2D;&#xFF0C;&#x6211;&#x4EEC;&#x5728;&#x4EE3;&#x7801;&#x4E2D;&#x90FD;&#x662F;&#x4F7F;&#x7528;&#x5B57;&#x9762;&#x91CF;&#x786C;&#x7F16;&#x7801;&#x7684;&#xFF0C;&#x5982;&#x679C;&#x6211;&#x4EEC;&#x60F3;&#x8981;&#x5728;&#x521B;&#x5EFA;&#x3001;&#x4FEE;&#x6539;&#x57FA;&#x7840;&#x8BBE;&#x65BD;&#x65F6;&#x52A8;&#x6001;&#x4F20;&#x5165;&#x4E00;&#x4E9B;&#x503C;&#x5462;&#xFF1F;&#x6BD4;&#x5982;&#x8BF4;&#x5728;&#x4EE3;&#x7801;&#x4E2D;&#x5B9A;&#x4E49; Provider &#x65F6;&#x7528;&#x53D8;&#x91CF;&#x66FF;&#x4EE3;&#x786C;&#x7F16;&#x7801;&#x7684;&#x8BBF;&#x95EE;&#x5BC6;&#x94A5;&#xFF0C;&#x6216;&#x662F;&#x7531;&#x521B;&#x5EFA;&#x57FA;&#x7840;&#x8BBE;&#x65BD;&#x7684;&#x7528;&#x6237;&#x6765;&#x51B3;&#x5B9A;&#x521B;&#x5EFA;&#x4EC0;&#x4E48;&#x6837;&#x5C3A;&#x5BF8;&#x7684;&#x4E3B;&#x673A;&#xFF1F;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x7684;&#x662F;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x3002;</p>
<p>&#x5982;&#x679C;&#x6211;&#x4EEC;&#x628A;&#x4E00;&#x7EC4; Terraform &#x4EE3;&#x7801;&#x60F3;&#x50CF;&#x6210;&#x4E00;&#x4E2A;&#x51FD;&#x6570;&#xFF0C;&#x90A3;&#x4E48;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x5C31;&#x662F;&#x51FD;&#x6570;&#x7684;&#x5165;&#x53C2;&#x3002;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x7528; <code>variable</code> &#x5757;&#x8FDB;&#x884C;&#x5B9A;&#x4E49;&#xFF1A;</p>
<pre class="language-"><code class="lang-hcl"><span class="token keyword">variable<span class="token type variable"> &quot;image_id&quot; </span></span><span class="token punctuation">{</span>
  <span class="token property">type</span> <span class="token punctuation">=</span> string
<span class="token punctuation">}</span>

<span class="token keyword">variable<span class="token type variable"> &quot;availability_zone_names&quot; </span></span><span class="token punctuation">{</span>
  <span class="token property">type</span>    <span class="token punctuation">=</span> list(string)
  <span class="token property">default</span> <span class="token punctuation">=</span> <span class="token punctuation">[</span><span class="token string">&quot;us-west-1a&quot;</span><span class="token punctuation">]</span>
<span class="token punctuation">}</span>

<span class="token keyword">variable<span class="token type variable"> &quot;docker_ports&quot; </span></span><span class="token punctuation">{</span>
  <span class="token property">type</span> <span class="token punctuation">=</span> list(object(<span class="token punctuation">{</span>
    <span class="token property">internal</span> <span class="token punctuation">=</span> number
    <span class="token property">external</span> <span class="token punctuation">=</span> number
    <span class="token property">protocol</span> <span class="token punctuation">=</span> string
  <span class="token punctuation">}</span>))
  <span class="token property">default</span> <span class="token punctuation">=</span> <span class="token punctuation">[</span>
    <span class="token punctuation">{</span>
      <span class="token property">internal</span> <span class="token punctuation">=</span> <span class="token number">8300</span>
      <span class="token property">external</span> <span class="token punctuation">=</span> <span class="token number">8300</span>
      <span class="token property">protocol</span> <span class="token punctuation">=</span> <span class="token string">&quot;tcp&quot;</span>
    <span class="token punctuation">}</span>
  <span class="token punctuation">]</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x8FD9;&#x4E9B;&#x90FD;&#x662F;&#x5408;&#x6CD5;&#x7684;&#x8F93;&#x5165;&#x53C2;&#x6570;&#x5B9A;&#x4E49;&#x3002;&#x7D27;&#x8DDF; <code>variable</code> &#x5173;&#x952E;&#x5B57;&#x7684;&#x5C31;&#x662F;&#x53D8;&#x91CF;&#x540D;&#x3002;&#x5728;&#x4E00;&#x4E2A; Terraform &#x6A21;&#x5757;(&#x540C;&#x4E00;&#x4E2A;&#x6587;&#x4EF6;&#x5939;&#x4E2D;&#x7684;&#x6240;&#x6709; Terraform &#x4EE3;&#x7801;&#x6587;&#x4EF6;&#xFF0C;&#x4E0D;&#x5305;&#x542B;&#x5B50;&#x6587;&#x4EF6;&#x5939;)&#x4E2D;&#x53D8;&#x91CF;&#x540D;&#x5FC5;&#x987B;&#x662F;&#x552F;&#x4E00;&#x7684;&#x3002;&#x6211;&#x4EEC;&#x5728;&#x4EE3;&#x7801;&#x4E2D;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;<code>var.<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>NAME</span><span class="token punctuation">&gt;</span></span></code>&#x7684;&#x65B9;&#x5F0F;&#x5F15;&#x7528;&#x53D8;&#x91CF;&#x7684;&#x503C;&#x3002;&#x6709;&#x4E00;&#x7EC4;&#x5173;&#x952E;&#x5B57;<strong>&#x4E0D;&#x53EF;&#x4EE5;</strong>&#x88AB;&#x7528;&#x4F5C;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x7684;&#x540D;&#x5B57;&#xFF1A;</p>
<ul>
<li><code>source</code></li>
<li><code>version</code></li>
<li><code>providers</code></li>
<li><code>count</code></li>
<li><code>for_each</code></li>
<li><code>lifecycle</code></li>
<li><code>depends_on</code></li>
<li><code>locals</code></li>
</ul>
<p>&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x53EA;&#x80FD;&#x5728;&#x58F0;&#x660E;&#x8BE5;&#x53D8;&#x91CF;&#x7684;&#x76EE;&#x5F55;&#x4E0B;&#x7684;&#x4EE3;&#x7801;&#x4E2D;&#x4F7F;&#x7528;&#x3002;</p>
<p>&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x5757;&#x4E2D;&#x53EF;&#x4EE5;&#x5B9A;&#x4E49;&#x4E00;&#x4E9B;&#x5C5E;&#x6027;&#x3002;</p>
<h2 id="&#x7C7B;&#x578B;-type"><a name="&#x7C7B;&#x578B;-type" class="anchor-navigation-ex-anchor" href="#&#x7C7B;&#x578B;-type"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.3.1.1. &#x7C7B;&#x578B; (type)</h2>
<p>&#x53EF;&#x4EE5;&#x5728;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x5757;&#x4E2D;&#x901A;&#x8FC7; <code>type</code> &#x5B9A;&#x4E49;&#x7C7B;&#x578B;&#xFF0C;&#x4F8B;&#x5982;&#xFF1A;</p>
<pre class="language-"><code class="lang-hcl"><span class="token keyword">variable<span class="token type variable"> &quot;name&quot; </span></span><span class="token punctuation">{</span>
    <span class="token property">type</span> <span class="token punctuation">=</span> string
<span class="token punctuation">}</span>
<span class="token keyword">variable<span class="token type variable"> &quot;ports&quot; </span></span><span class="token punctuation">{</span>
    <span class="token property">type</span> <span class="token punctuation">=</span> list(number)
<span class="token punctuation">}</span>
</code></pre>
<p>&#x5B9A;&#x4E49;&#x4E86;&#x7C7B;&#x578B;&#x7684;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x53EA;&#x80FD;&#x88AB;&#x8D4B;&#x4E88;&#x7B26;&#x5408;&#x7C7B;&#x578B;&#x7EA6;&#x675F;&#x7684;&#x503C;&#x3002;</p>
<h2 id="&#x9ED8;&#x8BA4;&#x503C;-default"><a name="&#x9ED8;&#x8BA4;&#x503C;-default" class="anchor-navigation-ex-anchor" href="#&#x9ED8;&#x8BA4;&#x503C;-default"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.3.1.2. &#x9ED8;&#x8BA4;&#x503C; (default)</h2>
<p>&#x9ED8;&#x8BA4;&#x503C;&#x5B9A;&#x4E49;&#x4E86;&#x5F53; Terraform &#x65E0;&#x6CD5;&#x83B7;&#x5F97;&#x4E00;&#x4E2A;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x5F97;&#x5230;&#x503C;&#x7684;&#x65F6;&#x5019;&#x4F1A;&#x4F7F;&#x7528;&#x7684;&#x9ED8;&#x8BA4;&#x503C;&#x3002;&#x4F8B;&#x5982;&#xFF1A;</p>
<pre class="language-"><code class="lang-hcl"><span class="token keyword">variable<span class="token type variable"> &quot;name&quot; </span></span><span class="token punctuation">{</span>
    <span class="token property">type</span>    <span class="token punctuation">=</span> string
    <span class="token property">default</span> <span class="token punctuation">=</span> <span class="token string">&quot;John Doe&quot;</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x5F53; Terraform &#x65E0;&#x6CD5;&#x901A;&#x8FC7;&#x5176;&#x4ED6;&#x9014;&#x5F84;&#x83B7;&#x5F97;name&#x7684;&#x503C;&#x65F6;&#xFF0C;<code>var.name</code> &#x7684;&#x503C;&#x4E3A; <code>&quot;John Doe&quot;</code>&#x3002;</p>
<h2 id="&#x63CF;&#x8FF0;-description"><a name="&#x63CF;&#x8FF0;-description" class="anchor-navigation-ex-anchor" href="#&#x63CF;&#x8FF0;-description"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.3.1.3. &#x63CF;&#x8FF0; (description)</h2>
<p>&#x53EF;&#x4EE5;&#x5728;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x4E2D;&#x5B9A;&#x4E49;&#x4E00;&#x4E2A;&#x63CF;&#x8FF0;&#xFF0C;&#x7B80;&#x5355;&#x5730;&#x5411;&#x8C03;&#x7528;&#x8005;&#x63CF;&#x8FF0;&#x8BE5;&#x53D8;&#x91CF;&#x7684;&#x610F;&#x4E49;&#x548C;&#x7528;&#x6CD5;&#xFF1A;</p>
<pre class="language-"><code class="lang-hcl"><span class="token keyword">variable<span class="token type variable"> &quot;image_id&quot; </span></span><span class="token punctuation">{</span>
  <span class="token property">type</span>        <span class="token punctuation">=</span> string
  <span class="token property">description</span> <span class="token punctuation">=</span> <span class="token string">&quot;The id of the machine image (AMI) to use for the server.&quot;</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x5982;&#x679C;&#x5728;&#x6267;&#x884C; <code>terraform plan</code> &#x6216;&#x662F; <code>terraform apply</code> &#x65F6; Terraform &#x4E0D;&#x77E5;&#x9053;&#x67D0;&#x4E2A;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x7684;&#x503C;&#xFF0C;Terraform &#x4F1A;&#x5728;&#x547D;&#x4EE4;&#x884C;&#x754C;&#x9762;&#x4E0A;&#x63D0;&#x793A;&#x6211;&#x4EEC;&#x4E3A;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x8BBE;&#x7F6E;&#x4E00;&#x4E2A;&#x503C;&#x3002;&#x4F8B;&#x5982;&#x4E0A;&#x9762;&#x7684;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x4EE3;&#x7801;&#xFF0C;&#x6267;&#x884C; <code>terraform apply</code> &#x65F6;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash">$ terraform apply
var.image_id
  The <span class="token function">id</span> of the machine image <span class="token punctuation">(</span>AMI<span class="token punctuation">)</span> to use <span class="token keyword">for</span> the server.

  Enter a value:
</code></pre>
<p>&#x4E3A;&#x4E86;&#x4F7F;&#x5F97;&#x4EE3;&#x7801;&#x7684;&#x4F7F;&#x7528;&#x8005;&#x80FD;&#x591F;&#x51C6;&#x786E;&#x7406;&#x89E3;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x7684;&#x610F;&#x4E49;&#x548C;&#x7528;&#x6CD5;&#xFF0C;&#x6211;&#x4EEC;&#x5E94;&#x8BE5;&#x7AD9;&#x5728;&#x4EE3;&#x7801;&#x4F7F;&#x7528;&#x8005;&#x800C;&#x975E;&#x4EE3;&#x7801;&#x7EF4;&#x62A4;&#x8005;&#x7684;&#x89D2;&#x5EA6;&#x7F16;&#x5199;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x7684;&#x63CF;&#x8FF0;&#x3002;<strong>&#x63CF;&#x8FF0;&#x5E76;&#x4E0D;&#x662F;&#x6CE8;&#x91CA;&#xFF01;</strong></p>
<h2 id="&#x65AD;&#x8A00;-validation"><a name="&#x65AD;&#x8A00;-validation" class="anchor-navigation-ex-anchor" href="#&#x65AD;&#x8A00;-validation"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.3.1.4. &#x65AD;&#x8A00; (validation)</h2>
<p>&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x7684;&#x65AD;&#x8A00;&#x662F; Terraform 0.13.0 &#x5F00;&#x59CB;&#x5F15;&#x5165;&#x7684;&#x65B0;&#x529F;&#x80FD;&#xFF0C;&#x5728;&#x8FC7;&#x53BB;&#xFF0C;Terraform &#x53EA;&#x80FD;&#x7528;&#x7C7B;&#x578B;&#x7EA6;&#x675F;&#x786E;&#x4FDD;&#x8F93;&#x5165;&#x53C2;&#x6570;&#x7684;&#x7C7B;&#x578B;&#x662F;&#x6B63;&#x786E;&#x7684;&#xFF0C;&#x66FE;&#x7ECF;&#x6709;&#x4E0D;&#x5C11;&#x4EBA;&#x8BD5;&#x56FE;&#x901A;&#x8FC7;&#x5947;&#x6280;&#x6DEB;&#x5DE7;&#x6765;&#x5B9E;&#x73B0;&#x66F4;&#x52A0;&#x590D;&#x6742;&#x7684;&#x53D8;&#x91CF;&#x6821;&#x9A8C;&#x65AD;&#x8A00;&#x3002;&#x5982;&#x4ECA; Terraform &#x7EC8;&#x4E8E;&#x6B63;&#x5F0F;&#x6DFB;&#x52A0;&#x4E86;&#x76F8;&#x5173;&#x7684;&#x529F;&#x80FD;&#x3002;</p>
<pre class="language-"><code class="lang-hcl"><span class="token keyword">variable<span class="token type variable"> &quot;image_id&quot; </span></span><span class="token punctuation">{</span>
  <span class="token property">type</span>        <span class="token punctuation">=</span> string
  <span class="token property">description</span> <span class="token punctuation">=</span> <span class="token string">&quot;The id of the machine image (AMI) to use for the server.&quot;</span>

  <span class="token keyword">validation</span> <span class="token punctuation">{</span>
    <span class="token property">condition</span>     <span class="token punctuation">=</span> length(var.image_id) &gt; <span class="token number">4</span> &amp;&amp; substr(var.image_id, <span class="token number">0</span>, <span class="token number">4</span>) <span class="token punctuation">=</span><span class="token punctuation">=</span> <span class="token string">&quot;ami-&quot;</span>
    <span class="token property">error_message</span> <span class="token punctuation">=</span> <span class="token string">&quot;The image_id value must be a valid AMI id, starting with \&quot;ami-\&quot;.&quot;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p><code>condition</code> &#x53C2;&#x6570;&#x662F;&#x4E00;&#x4E2A; <code>bool</code> &#x7C7B;&#x578B;&#x7684;&#x53C2;&#x6570;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x7528;&#x4E00;&#x4E2A;&#x8868;&#x8FBE;&#x5F0F;&#x6765;&#x5B9A;&#x4E49;&#x5982;&#x4F55;&#x754C;&#x5B9A;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x662F;&#x5408;&#x6CD5;&#x7684;&#x3002;&#x5F53; <code>condition</code> &#x4E3A; <code>true</code> &#x65F6;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x5408;&#x6CD5;&#xFF0C;&#x53CD;&#x4E4B;&#x4E0D;&#x5408;&#x6CD5;&#x3002;<code>condition</code> &#x8868;&#x8FBE;&#x5F0F;&#x4E2D;&#x53EA;&#x80FD;&#x901A;&#x8FC7; <code>var.\<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>NAME\</span><span class="token punctuation">&gt;</span></span></code> &#x5F15;&#x7528;&#x5F53;&#x524D;&#x5B9A;&#x4E49;&#x7684;&#x53D8;&#x91CF;&#xFF0C;&#x5E76;&#x4E14;&#x5B83;&#x7684;&#x8BA1;&#x7B97;&#x4E0D;&#x80FD;&#x4EA7;&#x751F;&#x9519;&#x8BEF;&#x3002;</p>
<p>&#x5047;&#x5982;&#x8868;&#x8FBE;&#x5F0F;&#x7684;&#x8BA1;&#x7B97;&#x4EA7;&#x751F;&#x4E00;&#x4E2A;&#x9519;&#x8BEF;&#x662F;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x9A8C;&#x8BC1;&#x7684;&#x4E00;&#x79CD;&#x5224;&#x5B9A;&#x624B;&#x6BB5;&#xFF0C;&#x90A3;&#x4E48;&#x53EF;&#x4EE5;&#x4F7F;&#x7528; <a href="https://developer.hashicorp.com/terraform/language/functions/can" target="_blank"><code>can</code> &#x51FD;&#x6570;</a>&#x6765;&#x5224;&#x5B9A;&#x8868;&#x8FBE;&#x5F0F;&#x7684;&#x6267;&#x884C;&#x662F;&#x5426;&#x629B;&#x9519;&#x3002;&#x4F8B;&#x5982;&#xFF1A;</p>
<pre class="language-"><code class="lang-hcl"><span class="token keyword">variable<span class="token type variable"> &quot;image_id&quot; </span></span><span class="token punctuation">{</span>
  <span class="token property">type</span>        <span class="token punctuation">=</span> string
  <span class="token property">description</span> <span class="token punctuation">=</span> <span class="token string">&quot;The id of the machine image (AMI) to use for the server.&quot;</span>

  <span class="token keyword">validation</span> <span class="token punctuation">{</span>
    <span class="token comment"># regex(...) fails if it cannot find a match</span>
    <span class="token property">condition</span>     <span class="token punctuation">=</span> can(regex(<span class="token string">&quot;^ami-&quot;</span>, var.image_id))
    <span class="token property">error_message</span> <span class="token punctuation">=</span> <span class="token string">&quot;The image_id value must be a valid AMI id, starting with \&quot;ami-\&quot;.&quot;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x4E0A;&#x8FF0;&#x4F8B;&#x5B50;&#x4E2D;&#xFF0C;&#x5982;&#x679C;&#x8F93;&#x5165;&#x7684; <code>image_id</code> &#x4E0D;&#x7B26;&#x5408;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x7684;&#x8981;&#x6C42;&#xFF0C;&#x90A3;&#x4E48; <code>regex</code> &#x51FD;&#x6570;&#x8C03;&#x7528;&#x4F1A;&#x629B;&#x51FA;&#x4E00;&#x4E2A;&#x9519;&#x8BEF;&#xFF0C;&#x8FD9;&#x4E2A;&#x9519;&#x8BEF;&#x4F1A;&#x88AB; <code>can</code> &#x51FD;&#x6570;&#x6355;&#x83B7;&#xFF0C;&#x8F93;&#x51FA; <code>false</code>&#x3002;</p>
<p><code>condition</code> &#x8868;&#x8FBE;&#x5F0F;&#x5982;&#x679C;&#x4E3A; <code>false</code>&#xFF0C;Terraform &#x4F1A;&#x8FD4;&#x56DE; <code>error_message</code> &#x4E2D;&#x5B9A;&#x4E49;&#x7684;&#x9519;&#x8BEF;&#x4FE1;&#x606F;&#x3002;<code>error_message</code> &#x5E94;&#x8BE5;&#x5B8C;&#x6574;&#x63CF;&#x8FF0;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x6821;&#x9A8C;&#x5931;&#x8D25;&#x7684;&#x539F;&#x56E0;&#xFF0C;&#x4EE5;&#x53CA;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x7684;&#x5408;&#x6CD5;&#x7EA6;&#x675F;&#x6761;&#x4EF6;&#x3002;</p>
<h2 id="&#x5728;&#x547D;&#x4EE4;&#x884C;&#x8F93;&#x51FA;&#x4E2D;&#x9690;&#x85CF;&#x503C;-sensitive"><a name="&#x5728;&#x547D;&#x4EE4;&#x884C;&#x8F93;&#x51FA;&#x4E2D;&#x9690;&#x85CF;&#x503C;-sensitive" class="anchor-navigation-ex-anchor" href="#&#x5728;&#x547D;&#x4EE4;&#x884C;&#x8F93;&#x51FA;&#x4E2D;&#x9690;&#x85CF;&#x503C;-sensitive"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.3.1.5. &#x5728;&#x547D;&#x4EE4;&#x884C;&#x8F93;&#x51FA;&#x4E2D;&#x9690;&#x85CF;&#x503C; (sensitive)</h2>
<p>&#x8BE5;&#x529F;&#x80FD;&#x4E8E; Terraform v0.14.0 &#x5F00;&#x59CB;&#x5F15;&#x5165;&#x3002;</p>
<p>&#x5C06;&#x53D8;&#x91CF;&#x8BBE;&#x7F6E;&#x4E3A; <code>sensitive</code> &#x53EF;&#x4EE5;&#x9632;&#x6B62;&#x6211;&#x4EEC;&#x5728;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x4E2D;&#x4F7F;&#x7528;&#x53D8;&#x91CF;&#x65F6; Terraform &#x5728; <code>plan</code> &#x548C; <code>apply</code> &#x547D;&#x4EE4;&#x7684;&#x8F93;&#x51FA;&#x4E2D;&#x5C55;&#x793A;&#x4E0E;&#x53D8;&#x91CF;&#x76F8;&#x5173;&#x7684;&#x503C;&#x3002;</p>
<p>Terraform <strong>&#x4ECD;&#x7136;&#x4F1A;</strong>&#x5C06;&#x654F;&#x611F;&#x6570;&#x636E;&#x8BB0;&#x5F55;&#x5728;<a href="2.2.Terraform&#x57FA;&#x7840;&#x6982;&#x5FF5;&#x2014;&#x2014;&#x72B6;&#x6001;&#x7BA1;&#x7406;.html">&#x72B6;&#x6001;&#x6587;&#x4EF6;</a>&#x4E2D;&#xFF0C;&#x4EFB;&#x4F55;&#x53EF;&#x4EE5;&#x8BBF;&#x95EE;&#x72B6;&#x6001;&#x6587;&#x4EF6;&#x7684;&#x4EBA;&#x90FD;<strong>&#x53EF;&#x4EE5;</strong>&#x8BFB;&#x53D6;&#x5230;&#x660E;&#x6587;&#x7684;&#x654F;&#x611F;&#x6570;&#x636E;&#x503C;&#x3002;</p>
<p>&#x58F0;&#x660E;&#x4E00;&#x4E2A;&#x53D8;&#x91CF;&#x5305;&#x542B;&#x654F;&#x611F;&#x6570;&#x636E;&#x503C;&#x9700;&#x8981;&#x5C06; <code>sensitive</code> &#x53C2;&#x6570;&#x8BBE;&#x7F6E;&#x4E3A; <code>true</code>&#xFF1A;</p>
<pre class="language-"><code class="lang-hcl"><span class="token keyword">variable<span class="token type variable"> &quot;user_information&quot; </span></span><span class="token punctuation">{</span>
  <span class="token property">type</span> <span class="token punctuation">=</span> object(<span class="token punctuation">{</span>
    <span class="token property">name</span>    <span class="token punctuation">=</span> string
    <span class="token property">address</span> <span class="token punctuation">=</span> string
  <span class="token punctuation">}</span>)
  <span class="token property">sensitive</span> <span class="token punctuation">=</span> <span class="token boolean">true</span>
<span class="token punctuation">}</span>

<span class="token keyword">resource <span class="token type variable">&quot;some_resource&quot;</span></span> <span class="token string">&quot;a&quot;</span> <span class="token punctuation">{</span>
  <span class="token property">name</span>    <span class="token punctuation">=</span> var.user_information.name
  <span class="token property">address</span> <span class="token punctuation">=</span> var.user_information.address
<span class="token punctuation">}</span>
</code></pre>
<p>&#x4EFB;&#x4F55;&#x4F7F;&#x7528;&#x4E86;&#x654F;&#x611F;&#x53D8;&#x91CF;&#x7684;&#x8868;&#x8FBE;&#x5F0F;&#x90FD;&#x5C06;&#x88AB;&#x89C6;&#x4E3A;&#x654F;&#x611F;&#x7684;&#xFF0C;&#x56E0;&#x6B64;&#x5728;&#x4E0A;&#x9762;&#x7684;&#x793A;&#x4F8B;&#x4E2D;&#xFF0C;<code>resource &#x201C;some_resource&#x201D; &#x201C;a&#x201D;</code>&#x7684;&#x4E24;&#x4E2A;&#x53C2;&#x6570;&#x4E5F;&#x5C06;&#x5728;&#x8BA1;&#x5212;&#x8F93;&#x51FA;&#x4E2D;&#x88AB;&#x9690;&#x85CF;&#xFF1A;</p>
<pre class="language-"><code class="lang-shell">Terraform will perform the following actions:

  <span class="token comment"># some_resource.a will be created</span>
  + resource <span class="token string">&quot;some_resource&quot;</span> <span class="token string">&quot;a&quot;</span> <span class="token punctuation">{</span>
      + name    <span class="token operator">=</span> <span class="token punctuation">(</span>sensitive<span class="token punctuation">)</span>
      + address <span class="token operator">=</span> <span class="token punctuation">(</span>sensitive<span class="token punctuation">)</span>
    <span class="token punctuation">}</span>

Plan: <span class="token number">1</span> to add, <span class="token number">0</span> to change, <span class="token number">0</span> to destroy.
</code></pre>
<p>&#x5728;&#x67D0;&#x4E9B;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x6211;&#x4EEC;&#x4F1A;&#x5728;&#x5D4C;&#x5957;&#x5757;&#x4E2D;&#x4F7F;&#x7528;&#x654F;&#x611F;&#x53D8;&#x91CF;&#xFF0C;Terraform &#x53EF;&#x80FD;&#x4F1A;&#x5C06;&#x6574;&#x4E2A;&#x5757;&#x89C6;&#x4E3A;&#x654F;&#x611F;&#x7684;&#x3002;&#x8FD9;&#x53D1;&#x751F;&#x5728;&#x90A3;&#x4E9B;&#x5305;&#x542B;&#x6709;&#x8981;&#x6C42;&#x503C;&#x662F;&#x552F;&#x4E00;&#x7684;&#x5185;&#x5D4C;&#x5757;&#x7684;&#x8D44;&#x6E90;&#x4E2D;&#xFF0C;&#x516C;&#x5F00;&#x8FD9;&#x79CD;&#x5185;&#x5D4C;&#x5757;&#x7684;&#x90E8;&#x5206;&#x5185;&#x5BB9;&#x53EF;&#x80FD;&#x4F1A;&#x6697;&#x793A;&#x5144;&#x5F1F;&#x5757;&#x7684;&#x5185;&#x5BB9;&#x3002;</p>
<pre class="language-"><code class="lang-shell"> <span class="token comment"># some_resource.a will be updated in-place</span>
  ~ resource <span class="token string">&quot;some_resource&quot;</span> <span class="token string">&quot;a&quot;</span> <span class="token punctuation">{</span>
      ~ nested_block <span class="token punctuation">{</span>
          <span class="token comment"># At least one attribute in this block is (or was) sensitive,</span>
          <span class="token comment"># so its contents will not be displayed.</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
</code></pre>
<p>Provider &#x8FD8;&#x53EF;&#x4EE5;&#x5C06;&#x8D44;&#x6E90;&#x5C5E;&#x6027;&#x58F0;&#x660E;&#x4E3A;&#x654F;&#x611F;&#x5C5E;&#x6027;&#xFF0C;&#x8FD9;&#x5C06;&#x5BFC;&#x81F4; Terraform &#x5C06;&#x5176;&#x4ECE;&#x5E38;&#x89C4;&#x8F93;&#x51FA;&#x4E2D;&#x9690;&#x85CF;&#x3002;</p>
<p>&#x5982;&#x679C;&#x6253;&#x7B97;&#x4F7F;&#x7528;&#x654F;&#x611F;&#x503C;&#x4F5C;&#x4E3A;&#x8F93;&#x51FA;&#x503C;&#x7684;&#x4E00;&#x90E8;&#x5206;&#xFF0C;Terraform &#x5C06;&#x8981;&#x6C42;&#x60A8;&#x5C06;&#x8F93;&#x51FA;&#x503C;&#x672C;&#x8EAB;&#x6807;&#x8BB0;&#x4E3A;&#x654F;&#x611F;&#x503C;&#xFF0C;&#x4EE5;&#x786E;&#x8BA4;&#x786E;&#x5B9E;&#x6253;&#x7B97;&#x5C06;&#x5176;&#x5BFC;&#x51FA;&#x3002;</p>
<h3 id="terraform-&#x53EF;&#x80FD;&#x66B4;&#x9732;&#x654F;&#x611F;&#x53D8;&#x91CF;&#x7684;&#x60C5;&#x51B5;"><a name="terraform-&#x53EF;&#x80FD;&#x66B4;&#x9732;&#x654F;&#x611F;&#x53D8;&#x91CF;&#x7684;&#x60C5;&#x51B5;" class="anchor-navigation-ex-anchor" href="#terraform-&#x53EF;&#x80FD;&#x66B4;&#x9732;&#x654F;&#x611F;&#x53D8;&#x91CF;&#x7684;&#x60C5;&#x51B5;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.3.1.5.1. Terraform &#x53EF;&#x80FD;&#x66B4;&#x9732;&#x654F;&#x611F;&#x53D8;&#x91CF;&#x7684;&#x60C5;&#x51B5;</h3>
<p><code>sensitive</code> &#x53D8;&#x91CF;&#x662F;&#x4E00;&#x4E2A;&#x4EE5;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x4E3A;&#x4E2D;&#x5FC3;&#x7684;&#x6982;&#x5FF5;&#xFF0C;&#x503C;&#x88AB;&#x4E0D;&#x52A0;&#x6DF7;&#x6DC6;&#x5730;&#x53D1;&#x9001;&#x7ED9; Provider&#x3002;&#x5982;&#x679C;&#x8BE5;&#x503C;&#x88AB;&#x5305;&#x542B;&#x5728;&#x9519;&#x8BEF;&#x6D88;&#x606F;&#x4E2D;&#xFF0C;&#x5219; Provider &#x62A5;&#x9519;&#x65F6;&#x53EF;&#x80FD;&#x4F1A;&#x66B4;&#x9732;&#x8BE5;&#x503C;&#x3002;&#x4F8B;&#x5982;&#xFF0C;&#x5373;&#x4F7F; <code>&quot;foo&quot;</code> &#x662F;&#x654F;&#x611F;&#x503C;&#xFF0C;Provider &#x4E5F;&#x53EF;&#x80FD;&#x8FD4;&#x56DE;&#x4EE5;&#x4E0B;&#x9519;&#x8BEF;&#xFF1A;<code>&quot;Invalid value &apos;foo&apos; for field&quot;</code></p>
<p>&#x5982;&#x679C;&#x5C06;&#x8D44;&#x6E90;&#x5C5E;&#x6027;&#x7528;&#x4F5C;&#x3001;&#x6216;&#x662F;&#x4F5C;&#x4E3A; Provider &#x5B9A;&#x4E49;&#x7684;&#x8D44;&#x6E90; ID &#x7684;&#x4E00;&#x90E8;&#x5206;&#xFF0C;&#x5219; <code>apply</code> &#x5C06;&#x516C;&#x5F00;&#x8BE5;&#x503C;&#x3002;&#x5728;&#x4E0B;&#x9762;&#x7684;&#x793A;&#x4F8B;&#x4E2D;&#xFF0C;&#x524D;&#x7F00;&#x5C5E;&#x6027;&#x5DF2;&#x8BBE;&#x7F6E;&#x4E3A; <code>sensitive</code> &#x53D8;&#x91CF;&#xFF0C;&#x4F46;&#x968F;&#x540E;&#x8BE5;&#x503C;&#xFF08;<code>&quot;jae&quot;</code>&#xFF09;&#x4F5C;&#x4E3A;&#x8D44;&#x6E90; ID &#x7684;&#x4E00;&#x90E8;&#x5206;&#x516C;&#x5F00;&#xFF1A;</p>
<pre class="language-"><code class="lang-shell">  <span class="token comment"># random_pet.animal will be created</span>
  + resource <span class="token string">&quot;random_pet&quot;</span> <span class="token string">&quot;animal&quot;</span> <span class="token punctuation">{</span>
      + <span class="token function">id</span>        <span class="token operator">=</span> <span class="token punctuation">(</span>known after apply<span class="token punctuation">)</span>
      + length    <span class="token operator">=</span> <span class="token number">2</span>
      + prefix    <span class="token operator">=</span> <span class="token punctuation">(</span>sensitive<span class="token punctuation">)</span>
      + separator <span class="token operator">=</span> <span class="token string">&quot;-&quot;</span>
    <span class="token punctuation">}</span>

Plan: <span class="token number">1</span> to add, <span class="token number">0</span> to change, <span class="token number">0</span> to destroy.

<span class="token punctuation">..</span>.

random_pet.animal: Creating<span class="token punctuation">..</span>.
random_pet.animal: Creation complete after 0s <span class="token punctuation">[</span>id<span class="token operator">=</span>jae-known-mongoose<span class="token punctuation">]</span>
</code></pre>
<h2 id="&#x7981;&#x6B62;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x4E3A;&#x7A7A;-nullable"><a name="&#x7981;&#x6B62;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x4E3A;&#x7A7A;-nullable" class="anchor-navigation-ex-anchor" href="#&#x7981;&#x6B62;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x4E3A;&#x7A7A;-nullable"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.3.1.6. &#x7981;&#x6B62;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x4E3A;&#x7A7A; (nullable)</h2>
<p>&#x8BE5;&#x529F;&#x80FD;&#x81EA; Terraform v1.1.0 &#x5F00;&#x59CB;&#x88AB;&#x5F15;&#x5165;</p>
<p>&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x7684; <code>nullable</code> &#x53C2;&#x6570;&#x63A7;&#x5236;&#x6A21;&#x5757;&#x8C03;&#x7528;&#x8005;&#x662F;&#x5426;&#x53EF;&#x4EE5;&#x5C06; <code>null</code> &#x8D4B;&#x503C;&#x7ED9;&#x53D8;&#x91CF;&#x3002;</p>
<pre class="language-"><code class="lang-hcl"><span class="token keyword">variable<span class="token type variable"> &quot;example&quot; </span></span><span class="token punctuation">{</span>
  <span class="token property">type</span>     <span class="token punctuation">=</span> string
  <span class="token property">nullable</span> <span class="token punctuation">=</span> <span class="token boolean">false</span> 
<span class="token punctuation">}</span>
</code></pre>
<p><code>nullable</code> &#x7684;&#x9ED8;&#x8BA4;&#x503C;&#x4E3A; <code>true</code>&#x3002;&#x5F53; <code>nullable</code> &#x4E3A; <code>true</code> &#x65F6;&#xFF0C;<code>null</code> &#x662F;&#x53D8;&#x91CF;&#x7684;&#x6709;&#x6548;&#x503C;&#xFF0C;&#x5E76;&#x4E14;&#x6A21;&#x5757;&#x4EE3;&#x7801;&#x5FC5;&#x987B;&#x59CB;&#x7EC8;&#x8003;&#x8651;&#x53D8;&#x91CF;&#x503C;&#x4E3A; <code>null</code> &#x7684;&#x53EF;&#x80FD;&#x6027;&#x3002;&#x5C06; <code>null</code> &#x4F5C;&#x4E3A;&#x6A21;&#x5757;&#x8F93;&#x5165;&#x53C2;&#x6570;&#x4F20;&#x9012;&#x5C06;&#x8986;&#x76D6;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x4E0A;&#x5B9A;&#x4E49;&#x7684;&#x9ED8;&#x8BA4;&#x503C;&#x3002;</p>
<p>&#x5C06; <code>nullable</code> &#x8BBE;&#x7F6E;&#x4E3A; <code>false</code> &#x53EF;&#x786E;&#x4FDD;&#x53D8;&#x91CF;&#x503C;&#x5728;&#x6A21;&#x5757;&#x5185;&#x6C38;&#x8FDC;&#x4E0D;&#x4F1A;&#x4E3A;&#x7A7A;&#x3002;&#x5982;&#x679C; <code>nullable</code> &#x4E3A; <code>false</code> &#x5E76;&#x4E14;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x5B9A;&#x4E49;&#x6709;&#x9ED8;&#x8BA4;&#x503C;&#xFF0C;&#x5219;&#x5F53;&#x6A21;&#x5757;&#x8F93;&#x5165;&#x53C2;&#x6570;&#x4E3A; <code>null</code> &#x65F6;&#xFF0C;Terraform &#x5C06;&#x4F7F;&#x7528;&#x9ED8;&#x8BA4;&#x503C;&#x3002;</p>
<p><code>nullable</code> &#x53C2;&#x6570;&#x4EC5;&#x63A7;&#x5236;&#x53D8;&#x91CF;&#x7684;&#x76F4;&#x63A5;&#x503C;&#x53EF;&#x80FD;&#x4E3A; <code>null</code> &#x7684;&#x60C5;&#x51B5;&#x3002;&#x5BF9;&#x4E8E;&#x96C6;&#x5408;&#x6216;&#x5BF9;&#x8C61;&#x7C7B;&#x578B;&#x7684;&#x53D8;&#x91CF;&#xFF0C;&#x4F8B;&#x5982;&#x5217;&#x8868;&#x6216;&#x5BF9;&#x8C61;&#xFF0C;&#x8C03;&#x7528;&#x8005;&#x4ECD;&#x7136;&#x53EF;&#x4EE5;&#x5728;&#x96C6;&#x5408;&#x5143;&#x7D20;&#x6216;&#x5C5E;&#x6027;&#x4E2D;&#x4F7F;&#x7528; <code>null</code>&#xFF0C;&#x53EA;&#x8981;&#x96C6;&#x5408;&#x6216;&#x5BF9;&#x8C61;&#x672C;&#x8EAB;&#x4E0D;&#x4E3A; <code>null</code>&#x3002;</p>
<h2 id="&#x5BF9;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x8D4B;&#x503C;"><a name="&#x5BF9;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x8D4B;&#x503C;" class="anchor-navigation-ex-anchor" href="#&#x5BF9;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x8D4B;&#x503C;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.3.1.7. &#x5BF9;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x8D4B;&#x503C;</h2>
<h3 id="&#x547D;&#x4EE4;&#x884C;&#x53C2;&#x6570;"><a name="&#x547D;&#x4EE4;&#x884C;&#x53C2;&#x6570;" class="anchor-navigation-ex-anchor" href="#&#x547D;&#x4EE4;&#x884C;&#x53C2;&#x6570;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.3.1.7.1. &#x547D;&#x4EE4;&#x884C;&#x53C2;&#x6570;</h3>
<p>&#x5BF9;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x8D4B;&#x503C;&#x6709;&#x51E0;&#x79CD;&#x9014;&#x5F84;&#xFF0C;&#x4E00;&#x79CD;&#x662F;&#x5728;&#x8C03;&#x7528; <code>terraform plan</code> &#x6216;&#x662F; <code>terraform apply</code> &#x547D;&#x4EE4;&#x65F6;&#x4EE5;&#x53C2;&#x6570;&#x7684;&#x5F62;&#x5F0F;&#x4F20;&#x5165;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash">$ terraform apply <span class="token parameter variable">-var</span><span class="token operator">=</span><span class="token string">&quot;image_id=ami-abc123&quot;</span>
$ terraform apply <span class="token parameter variable">-var</span><span class="token operator">=</span><span class="token string">&apos;image_id_list=[&quot;ami-abc123&quot;,&quot;ami-def456&quot;]&apos;</span>
$ terraform plan <span class="token parameter variable">-var</span><span class="token operator">=</span><span class="token string">&apos;image_id_map={&quot;us-east-1&quot;:&quot;ami-abc123&quot;,&quot;us-east-2&quot;:&quot;ami-def456&quot;}&apos;</span>
</code></pre>
<p>&#x53EF;&#x4EE5;&#x5728;&#x4E00;&#x6761;&#x547D;&#x4EE4;&#x4E2D;&#x4F7F;&#x7528;&#x591A;&#x4E2A; <code>-var</code> &#x53C2;&#x6570;&#x3002;</p>
<h3 id="&#x53C2;&#x6570;&#x6587;&#x4EF6;"><a name="&#x53C2;&#x6570;&#x6587;&#x4EF6;" class="anchor-navigation-ex-anchor" href="#&#x53C2;&#x6570;&#x6587;&#x4EF6;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.3.1.7.2. &#x53C2;&#x6570;&#x6587;&#x4EF6;</h3>
<p>&#x7B2C;&#x4E8C;&#x79CD;&#x65B9;&#x6CD5;&#x662F;&#x4F7F;&#x7528;&#x53C2;&#x6570;&#x6587;&#x4EF6;&#x3002;&#x53C2;&#x6570;&#x6587;&#x4EF6;&#x7684;&#x540E;&#x7F00;&#x540D;&#x53EF;&#x4EE5;&#x662F; <code>.tfvars</code> &#x6216;&#x662F; <code>.tfvars.json</code>&#x3002;<code>.tfvars</code> &#x6587;&#x4EF6;&#x4F7F;&#x7528; HCL &#x8BED;&#x6CD5;&#xFF0C;<code>.tfvars.json</code> &#x4F7F;&#x7528; JSON &#x8BED;&#x6CD5;&#x3002;</p>
<p>&#x4EE5; <code>.tfvars</code> &#x4E3A;&#x4F8B;&#xFF0C;&#x53C2;&#x6570;&#x6587;&#x4EF6;&#x4E2D;&#x7528; HCL &#x4EE3;&#x7801;&#x5BF9;&#x9700;&#x8981;&#x8D4B;&#x503C;&#x7684;&#x53C2;&#x6570;&#x8FDB;&#x884C;&#x8D4B;&#x503C;&#xFF0C;&#x4F8B;&#x5982;&#xFF1A;</p>
<pre class="language-"><code class="lang-hcl"><span class="token property">image_id</span> <span class="token punctuation">=</span> <span class="token string">&quot;ami-abc123&quot;</span>
<span class="token property">availability_zone_names</span> <span class="token punctuation">=</span> <span class="token punctuation">[</span>
  <span class="token string">&quot;us-east-1a&quot;</span>,
  <span class="token string">&quot;us-west-1c&quot;</span>,
<span class="token punctuation">]</span>
</code></pre>
<p>&#x540E;&#x7F00;&#x540D;&#x4E3A; <code>.tfvars.json</code> &#x7684;&#x6587;&#x4EF6;&#x7528;&#x4E00;&#x4E2A; JSON &#x5BF9;&#x8C61;&#x6765;&#x5BF9;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x8D4B;&#x503C;&#xFF0C;&#x4F8B;&#x5982;&#xFF1A;</p>
<pre class="language-"><code class="lang-json"><span class="token punctuation">{</span>
  <span class="token property">&quot;image_id&quot;</span><span class="token operator">:</span> <span class="token string">&quot;ami-abc123&quot;</span><span class="token punctuation">,</span>
  <span class="token property">&quot;availability_zone_names&quot;</span><span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">&quot;us-west-1a&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;us-west-1c&quot;</span><span class="token punctuation">]</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x8C03;&#x7528; terraform &#x547D;&#x4EE4;&#x65F6;&#xFF0C;&#x901A;&#x8FC7; <code>-var-file</code> &#x53C2;&#x6570;&#x6307;&#x5B9A;&#x8981;&#x7528;&#x7684;&#x53C2;&#x6570;&#x6587;&#x4EF6;&#xFF0C;&#x4F8B;&#x5982;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash">terraform apply -var-file<span class="token operator">=</span><span class="token string">&quot;testing.tfvars&quot;</span>
</code></pre>
<pre class="language-"><code class="lang-bash">terraform apply -var-file<span class="token operator">=</span><span class="token string">&quot;testing.tfvars.json&quot;</span>
</code></pre>
<p>&#x6709;&#x4E24;&#x79CD;&#x60C5;&#x51B5;&#xFF0C;&#x4F60;<strong>&#x65E0;&#x9700;</strong>&#x6307;&#x5B9A;&#x53C2;&#x6570;&#x6587;&#x4EF6;&#xFF1A;</p>
<ul>
<li>&#x5F53;&#x524D;&#x6A21;&#x5757;&#x5185;&#x6709;&#x540D;&#x4E3A; <code>terraform.tfvars</code> &#x6216;&#x662F; <code>terraform.tfvars.json</code> &#x7684;&#x6587;&#x4EF6;</li>
<li>&#x5F53;&#x524D;&#x6A21;&#x5757;&#x5185;&#x6709;&#x4E00;&#x4E2A;&#x6216;&#x591A;&#x4E2A;&#x540E;&#x7F00;&#x540D;&#x4E3A; <code>.auto.tfvars</code> &#x6216;&#x662F; <code>.auto.tfvars.json</code> &#x7684;&#x6587;&#x4EF6;</li>
</ul>
<p>Terraform &#x4F1A;&#x81EA;&#x52A8;&#x4F7F;&#x7528;&#x8FD9;&#x4E24;&#x79CD;&#x81EA;&#x52A8;&#x53C2;&#x6570;&#x6587;&#x4EF6;&#x5BF9;&#x8F93;&#x5165;&#x53C2;&#x6570;&#x8D4B;&#x503C;&#x3002;</p>
<h3 id="&#x73AF;&#x5883;&#x53D8;&#x91CF;"><a name="&#x73AF;&#x5883;&#x53D8;&#x91CF;" class="anchor-navigation-ex-anchor" href="#&#x73AF;&#x5883;&#x53D8;&#x91CF;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.3.1.7.3. &#x73AF;&#x5883;&#x53D8;&#x91CF;</h3>
<p>&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x8BBE;&#x7F6E;&#x540D;&#x4E3A; <code>TF_VAR_<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>NAME</span><span class="token punctuation">&gt;</span></span></code> &#x7684;&#x73AF;&#x5883;&#x53D8;&#x91CF;&#x4E3A;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x8D4B;&#x503C;&#xFF0C;&#x4F8B;&#x5982;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash">$ <span class="token builtin class-name">export</span> <span class="token assign-left variable">TF_VAR_image_id</span><span class="token operator">=</span>ami-abc123
$ terraform plan
<span class="token punctuation">..</span>.
</code></pre>
<p>&#x5728;&#x73AF;&#x5883;&#x53D8;&#x91CF;&#x540D;&#x5927;&#x5C0F;&#x5199;&#x654F;&#x611F;&#x7684;&#x64CD;&#x4F5C;&#x7CFB;&#x7EDF;&#x4E0A;&#xFF0C;Terraform &#x8981;&#x6C42;&#x73AF;&#x5883;&#x53D8;&#x91CF;&#x4E2D;&#x7684; <code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>NAME</span><span class="token punctuation">&gt;</span></span></code> &#x4E0E; Terraform &#x4EE3;&#x7801;&#x4E2D;&#x5B9A;&#x4E49;&#x7684;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x540D;&#x5927;&#x5C0F;&#x5199;&#x5B8C;&#x5168;&#x4E00;&#x81F4;&#x3002;</p>
<p>&#x73AF;&#x5883;&#x53D8;&#x91CF;&#x4F20;&#x503C;&#x975E;&#x5E38;&#x9002;&#x5408;&#x5728;&#x81EA;&#x52A8;&#x5316;&#x6D41;&#x6C34;&#x7EBF;&#x4E2D;&#x4F7F;&#x7528;&#xFF0C;&#x5C24;&#x5176;&#x9002;&#x5408;&#x7528;&#x6765;&#x4F20;&#x9012;&#x654F;&#x611F;&#x6570;&#x636E;&#xFF0C;&#x7C7B;&#x4F3C;&#x5BC6;&#x7801;&#x3001;&#x8BBF;&#x95EE;&#x5BC6;&#x94A5;&#x7B49;&#x3002;</p>
<h3 id="&#x4EA4;&#x4E92;&#x754C;&#x9762;&#x4F20;&#x503C;"><a name="&#x4EA4;&#x4E92;&#x754C;&#x9762;&#x4F20;&#x503C;" class="anchor-navigation-ex-anchor" href="#&#x4EA4;&#x4E92;&#x754C;&#x9762;&#x4F20;&#x503C;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.3.1.7.4. &#x4EA4;&#x4E92;&#x754C;&#x9762;&#x4F20;&#x503C;</h3>
<p>&#x5728;&#x524D;&#x9762;&#x4ECB;&#x7ECD;&#x65AD;&#x8A00;&#x7684;&#x4F8B;&#x5B50;&#x4E2D;&#x6211;&#x4EEC;&#x770B;&#x5230;&#x8FC7;&#xFF0C;&#x5F53;&#x6211;&#x4EEC;&#x4ECE;&#x547D;&#x4EE4;&#x884C;&#x754C;&#x9762;&#x6267;&#x884C; terraform &#x64CD;&#x4F5C;&#xFF0C;Terraform &#x65E0;&#x6CD5;&#x901A;&#x8FC7;&#x5176;&#x4ED6;&#x9014;&#x5F84;&#x83B7;&#x53D6;&#x4E00;&#x4E2A;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x7684;&#x503C;&#xFF0C;&#x800C;&#x8BE5;&#x53D8;&#x91CF;&#x4E5F;&#x6CA1;&#x6709;&#x5B9A;&#x4E49;&#x9ED8;&#x8BA4;&#x503C;&#x65F6;&#xFF0C;Terraform &#x4F1A;&#x8FDB;&#x884C;&#x6700;&#x540E;&#x7684;&#x5C1D;&#x8BD5;&#xFF0C;&#x5728;&#x4EA4;&#x4E92;&#x754C;&#x9762;&#x4E0A;&#x8981;&#x6C42;&#x6211;&#x4EEC;&#x7ED9;&#x51FA;&#x53D8;&#x91CF;&#x503C;&#x3002;</p>
<h2 id="&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x8D4B;&#x503C;&#x4F18;&#x5148;&#x7EA7;"><a name="&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x8D4B;&#x503C;&#x4F18;&#x5148;&#x7EA7;" class="anchor-navigation-ex-anchor" href="#&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x8D4B;&#x503C;&#x4F18;&#x5148;&#x7EA7;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.3.1.8. &#x8F93;&#x5165;&#x53D8;&#x91CF;&#x8D4B;&#x503C;&#x4F18;&#x5148;&#x7EA7;</h2>
<p>&#x5F53;&#x4E0A;&#x8FF0;&#x7684;&#x8D4B;&#x503C;&#x65B9;&#x5F0F;&#x540C;&#x65F6;&#x5B58;&#x5728;&#x65F6;&#xFF0C;&#x540C;&#x4E00;&#x4E2A;&#x53D8;&#x91CF;&#x53EF;&#x80FD;&#x4F1A;&#x88AB;&#x8D4B;&#x503C;&#x591A;&#x6B21;&#x3002;Terraform &#x4F1A;&#x4F7F;&#x7528;&#x65B0;&#x503C;&#x8986;&#x76D6;&#x65E7;&#x503C;&#x3002;</p>
<p>Terraform &#x52A0;&#x8F7D;&#x53D8;&#x91CF;&#x503C;&#x7684;&#x987A;&#x5E8F;&#x662F;&#xFF1A;</p>
<ol>
<li>&#x73AF;&#x5883;&#x53D8;&#x91CF;</li>
<li><code>terraform.tfvars</code> &#x6587;&#x4EF6;(&#x5982;&#x679C;&#x5B58;&#x5728;&#x7684;&#x8BDD;)</li>
<li><code>terraform.tfvars.json</code> &#x6587;&#x4EF6;(&#x5982;&#x679C;&#x5B58;&#x5728;&#x7684;&#x8BDD;)</li>
<li>&#x6240;&#x6709;&#x7684; <code>.auto.tfvars</code> &#x6216;&#x8005; <code>.auto.tfvars.json</code> &#x6587;&#x4EF6;&#xFF0C;&#x4EE5;&#x5B57;&#x6BCD;&#x987A;&#x5E8F;&#x6392;&#x5E8F;&#x5904;&#x7406;</li>
<li>&#x901A;&#x8FC7; <code>-var</code> &#x6216;&#x662F; <code>-var-file</code> &#x547D;&#x4EE4;&#x884C;&#x53C2;&#x6570;&#x4F20;&#x9012;&#x7684;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#xFF0C;&#x6309;&#x7167;&#x5728;&#x547D;&#x4EE4;&#x884C;&#x53C2;&#x6570;&#x4E2D;&#x5B9A;&#x4E49;&#x7684;&#x987A;&#x5E8F;&#x52A0;&#x8F7D;</li>
</ol>
<p>&#x5047;&#x5982;&#x4EE5;&#x4E0A;&#x65B9;&#x5F0F;&#x5747;&#x672A;&#x80FD;&#x6210;&#x529F;&#x5BF9;&#x53D8;&#x91CF;&#x8D4B;&#x503C;&#xFF0C;&#x90A3;&#x4E48; Terraform &#x4F1A;&#x5C1D;&#x8BD5;&#x4F7F;&#x7528;&#x9ED8;&#x8BA4;&#x503C;&#xFF1B;&#x5BF9;&#x4E8E;&#x6CA1;&#x6709;&#x5B9A;&#x4E49;&#x9ED8;&#x8BA4;&#x503C;&#x7684;&#x53D8;&#x91CF;&#xFF0C;Terraform &#x4F1A;&#x91C7;&#x7528;&#x4EA4;&#x4E92;&#x754C;&#x9762;&#x65B9;&#x5F0F;&#x8981;&#x6C42;&#x7528;&#x6237;&#x8F93;&#x5165;&#x4E00;&#x4E2A;&#x3002;&#x5BF9;&#x4E8E;&#x67D0;&#x4E9B; Terraform &#x547D;&#x4EE4;&#xFF0C;&#x5982;&#x679C;&#x6267;&#x884C;&#x65F6;&#x5E26;&#x6709; <code>-input=false</code> &#x53C2;&#x6570;&#x7981;&#x7528;&#x4E86;&#x4EA4;&#x4E92;&#x754C;&#x9762;&#x4F20;&#x503C;&#x65B9;&#x5F0F;&#xFF0C;&#x90A3;&#x4E48;&#x5C31;&#x4F1A;&#x62A5;&#x9519;&#x3002;</p>
<p><strong>&#x91CD;&#x8981;&#x63D0;&#x793A;</strong>&#xFF1A;&#x5728; Terraform 0.12 &#x53CA;&#x66F4;&#x9AD8;&#x7248;&#x672C;&#x4E2D;&#xFF0C;&#x7C7B;&#x578B;&#x4E3A; <code>map</code> &#x6216; <code>object</code> &#x7684;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x7684;&#x8BFB;&#x53D6;&#x884C;&#x4E3A;&#x4E0E;&#x5176;&#x4ED6;&#x53D8;&#x91CF;&#x76F8;&#x540C;&#xFF1A;&#x540E;&#x627E;&#x5230;&#x7684;&#x503C;&#x4F1A;&#x8986;&#x76D6;&#x4E4B;&#x524D;&#x7684;&#x503C;&#x3002;&#x8FD9;&#x4E0E; Terraform &#x7684;&#x65E9;&#x671F;&#x7248;&#x672C;&#x4E0D;&#x540C;&#xFF0C;&#x65E9;&#x671F;&#x7248;&#x672C;&#x4F1A;&#x5408;&#x5E76; <code>map</code>&#xFF0C;&#x800C;&#x4E0D;&#x662F;&#x8986;&#x76D6;&#x5B83;&#x4EEC;&#x3002;</p>
<h3 id="terraform-&#x6D4B;&#x8BD5;&#x4E2D;&#x7684;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x503C;"><a name="terraform-&#x6D4B;&#x8BD5;&#x4E2D;&#x7684;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x503C;" class="anchor-navigation-ex-anchor" href="#terraform-&#x6D4B;&#x8BD5;&#x4E2D;&#x7684;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x503C;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.3.1.8.1. Terraform &#x6D4B;&#x8BD5;&#x4E2D;&#x7684;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#x503C;</h3>
<p>&#x5728; <a href="6.test.html">Terraform &#x6D4B;&#x8BD5;&#x6587;&#x4EF6;</a>&#x4E2D;&#xFF0C;&#x60A8;&#x53EF;&#x4EE5;&#x5728; <code>variable</code> &#x5757;&#x4E2D;&#x6307;&#x5B9A;&#x53D8;&#x91CF;&#x503C;&#xFF0C;&#x8FD9;&#x4E9B; <code>variable</code> &#x5757;&#x53EF;&#x4EE5;&#x5D4C;&#x5957;&#x5728; <code>run</code> &#x5757;&#x4E2D;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x5728;&#x6587;&#x4EF6;&#x4E2D;&#x5B9A;&#x4E49;&#x3002;</p>
<p>&#x4EE5;&#x8FD9;&#x79CD;&#x65B9;&#x5F0F;&#x5B9A;&#x4E49;&#x7684;&#x53D8;&#x91CF;&#x5728;&#x6D4B;&#x8BD5;&#x6267;&#x884C;&#x671F;&#x95F4;&#x4F18;&#x5148;&#x4E8E;&#x6240;&#x6709;&#x5176;&#x4ED6;&#x673A;&#x5236;&#xFF0C;&#x5176;&#x4E2D;&#x5728; <code>run</code> &#x5757;&#x4E2D;&#x5B9A;&#x4E49;&#x7684;&#x53D8;&#x91CF;&#x4F18;&#x5148;&#x4E8E;&#x5728;&#x6587;&#x4EF6;&#x4E2D;&#x5B9A;&#x4E49;&#x7684;&#x53D8;&#x91CF;&#x3002;</p>
<h2 id="&#x590D;&#x6742;&#x7C7B;&#x578B;&#x4F20;&#x503C;"><a name="&#x590D;&#x6742;&#x7C7B;&#x578B;&#x4F20;&#x503C;" class="anchor-navigation-ex-anchor" href="#&#x590D;&#x6742;&#x7C7B;&#x578B;&#x4F20;&#x503C;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.3.1.9. &#x590D;&#x6742;&#x7C7B;&#x578B;&#x4F20;&#x503C;</h2>
<p>&#x901A;&#x8FC7;&#x53C2;&#x6570;&#x6587;&#x4EF6;&#x4F20;&#x503C;&#x65F6;&#xFF0C;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x4F7F;&#x7528; HCL &#x6216;&#x662F; JSON &#x8BED;&#x6CD5;&#x5BF9;&#x590D;&#x6742;&#x7C7B;&#x578B;&#x4F20;&#x503C;&#xFF0C;&#x4F8B;&#x5982; <code>list</code> &#x6216; <code>map</code>&#x3002;</p>
<p>&#x5BF9;&#x4E8E;&#x67D0;&#x4E9B;&#x573A;&#x666F;&#x4E0B;&#x5FC5;&#x987B;&#x4F7F;&#x7528; <code>-var</code> &#x547D;&#x4EE4;&#x884C;&#x53C2;&#x6570;&#xFF0C;&#x6216;&#x662F;&#x73AF;&#x5883;&#x53D8;&#x91CF;&#x4F20;&#x503C;&#x65F6;&#xFF0C;&#x53EF;&#x4EE5;&#x7528;&#x5355;&#x5F15;&#x53F7;&#x5F15;&#x7528; HCL &#x8BED;&#x6CD5;&#x7684;&#x5B57;&#x9762;&#x91CF;&#x6765;&#x5B9A;&#x4E49;&#x590D;&#x6742;&#x7C7B;&#x578B;&#xFF0C;&#x4F8B;&#x5982;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash"><span class="token builtin class-name">export</span> <span class="token assign-left variable">TF_VAR_availability_zone_names</span><span class="token operator">=</span><span class="token string">&apos;[&quot;us-west-1b&quot;,&quot;us-west-1d&quot;]&apos;</span>
</code></pre>
<p>&#x7531;&#x4E8E;&#x91C7;&#x7528;&#x8FD9;&#x79CD;&#x65B9;&#x6CD5;&#x9700;&#x8981;&#x624B;&#x5DE5;&#x5904;&#x7406;&#x5F15;&#x53F7;&#x7684;&#x8F6C;&#x4E49;&#xFF0C;&#x6240;&#x4EE5;&#x8FD9;&#x79CD;&#x65B9;&#x6CD5;&#x6BD4;&#x8F83;&#x5BB9;&#x6613;&#x51FA;&#x9519;&#xFF0C;&#x590D;&#x6742;&#x7C7B;&#x578B;&#x7684;&#x4F20;&#x503C;&#x5EFA;&#x8BAE;&#x5C3D;&#x91CF;&#x901A;&#x8FC7;&#x53C2;&#x6570;&#x6587;&#x4EF6;&#x3002;</p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="3.2.配置语法.html" class="navigation navigation-prev " aria-label="Previous page: 配置语法">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="3.4.输出值.html" class="navigation navigation-next " aria-label="Next page: 输出值">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"输入变量","level":"1.4.3","depth":2,"next":{"title":"输出值","level":"1.4.4","depth":2,"path":"3.4.输出值.md","ref":"./3.4.输出值.md","articles":[]},"previous":{"title":"配置语法","level":"1.4.2","depth":2,"path":"3.2.配置语法.md","ref":"./3.2.配置语法.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-highlight","prism","prism-themes","fontsettings","sharing","-lunr","-search","search-pro","livereload","image-captions","sitemap-general","anchor-navigation-ex"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"prism":{"css":["prism-themes/themes/prism-vsc-dark-plus.css"],"lang":{"shell":"bash","cmd":"bash"}},"livereload":{},"search-pro":{},"sitemap-general":{"prefix":"https://lonegunmanb.github.io/introduction-terraform/"},"fontsettings":{"family":"sans","size":2,"theme":"white"},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"mode":"float","multipleH1":true,"pageTop":{"level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"printLog":false,"showGoTop":true,"showLevel":true},"prism-themes":{},"sharing":{"all":["facebook","google","twitter","weibo","instapaper"],"facebook":true,"google":false,"instapaper":false,"twitter":true,"vk":false,"weibo":false},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":true},"image-captions":{"caption":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","variable_name":"_pictures"}},"theme":"default","author":"大可不加冰","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{"_pictures":[{"backlink":"index.html#fig1.1.1","level":"1.1","list_caption":"Figure: Nomad、Consul、Vault、Terraform 组成的 HashiStack","alt":"Nomad、Consul、Vault、Terraform 组成的 HashiStack","nro":1,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/2020-11-13/1605243540985-image.png","index":1,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"Nomad、Consul、Vault、Terraform 组成的 HashiStack","attributes":{},"skip":false,"key":"1.1.1"},{"backlink":"index.html#fig1.1.2","level":"1.1","list_caption":"Figure: Terraform 著名教材《Terraform Up & Running》，建议直接阅读第二版","alt":"Terraform 著名教材《Terraform Up & Running》，建议直接阅读第二版","nro":2,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/2020-12-23/1608689176373-image.png","index":2,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"Terraform 著名教材《Terraform Up & Running》，建议直接阅读第二版","attributes":{},"skip":false,"key":"1.1.2"},{"backlink":"./2.1.Terraform基础概念——Provider.html#fig1.3.1.1","level":"1.3.1","list_caption":"Figure: Terraform通过RPC调用插件，插件代码通过调用SDK操作远程资源","alt":"Terraform通过RPC调用插件，插件代码通过调用SDK操作远程资源","nro":3,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/2020-11-16/1605496195438-image.png","index":1,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"Terraform通过RPC调用插件，插件代码通过调用SDK操作远程资源","attributes":{},"skip":false,"key":"1.3.1.1"},{"backlink":"./2.1.Terraform基础概念——Provider.html#fig1.3.1.2","level":"1.3.1","list_caption":"Figure: registry.terraform.io上的插件页面","alt":"registry.terraform.io上的插件页面","nro":4,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/2020-11-19/1605799350775-image.png","index":2,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"registry.terraform.io上的插件页面","attributes":{},"skip":false,"key":"1.3.1.2"},{"backlink":"./2.1.Terraform基础概念——Provider.html#fig1.3.1.3","level":"1.3.1","list_caption":"Figure: registry.terraform.io的搜索页面","alt":"registry.terraform.io的搜索页面","nro":5,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/2020-11-16/1605498907942-image.png","index":3,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"registry.terraform.io的搜索页面","attributes":{},"skip":false,"key":"1.3.1.3"},{"backlink":"./2.2.Terraform基础概念——状态管理.html#fig1.3.2.1","level":"1.3.2","list_caption":"Figure: Consul的GUI界面","alt":"Consul的GUI界面","nro":6,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/20240220224455.png","index":1,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"Consul的GUI界面","attributes":{},"skip":false,"key":"1.3.2.1"},{"backlink":"./2.2.Terraform基础概念——状态管理.html#fig1.3.2.2","level":"1.3.2","list_caption":"Figure: Consul 中可以看到名为 `localstack-aws` 的键","alt":"Consul 中可以看到名为 `localstack-aws` 的键","nro":7,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/20240220230042.png","index":2,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"Consul 中可以看到名为 `localstack-aws` 的键","attributes":{},"skip":false,"key":"1.3.2.2"},{"backlink":"./2.2.Terraform基础概念——状态管理.html#fig1.3.2.3","level":"1.3.2","list_caption":"Figure: 键的内容","alt":"键的内容","nro":8,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/20240220230136.png","index":3,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"键的内容","attributes":{},"skip":false,"key":"1.3.2.3"},{"backlink":"./2.2.Terraform基础概念——状态管理.html#fig1.3.2.4","level":"1.3.2","list_caption":"Figure: 键依然存在","alt":"键依然存在","nro":9,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/20240220230312.png","index":4,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"键依然存在","attributes":{},"skip":false,"key":"1.3.2.4"},{"backlink":"./2.2.Terraform基础概念——状态管理.html#fig1.3.2.5","level":"1.3.2","list_caption":"Figure: 内容已被清空","alt":"内容已被清空","nro":10,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/20240220230350.png","index":5,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"内容已被清空","attributes":{},"skip":false,"key":"1.3.2.5"},{"backlink":"./2.2.Terraform基础概念——状态管理.html#fig1.3.2.6","level":"1.3.2","list_caption":"Figure: 多了一个同名的文件夹","alt":"多了一个同名的文件夹","nro":11,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/20240225100309.png","index":6,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"多了一个同名的文件夹","attributes":{},"skip":false,"key":"1.3.2.6"},{"backlink":"./2.2.Terraform基础概念——状态管理.html#fig1.3.2.7","level":"1.3.2","list_caption":"Figure: localstack-aws 文件夹内部","alt":"localstack-aws 文件夹内部","nro":12,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/20240225100354.png","index":7,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"localstack-aws 文件夹内部","attributes":{},"skip":false,"key":"1.3.2.7"},{"backlink":"./2.2.Terraform基础概念——状态管理.html#fig1.3.2.8","level":"1.3.2","list_caption":"Figure: `.lock` 内容","alt":"`.lock` 内容","nro":13,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/20240225180803.png","index":8,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"`.lock` 内容","attributes":{},"skip":false,"key":"1.3.2.8"},{"backlink":"./2.2.Terraform基础概念——状态管理.html#fig1.3.2.9","level":"1.3.2","list_caption":"Figure: `.lockinfo` 内容","alt":"`.lockinfo` 内容","nro":14,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/20240225180852.png","index":9,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"`.lockinfo` 内容","attributes":{},"skip":false,"key":"1.3.2.9"},{"backlink":"./2.2.Terraform基础概念——状态管理.html#fig1.3.2.10","level":"1.3.2","list_caption":"Figure: 重新访问Consul","alt":"重新访问Consul","nro":15,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/20240225101100.png","index":10,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"重新访问Consul","attributes":{},"skip":false,"key":"1.3.2.10"},{"backlink":"./2.2.Terraform基础概念——状态管理.html#fig1.3.2.11","level":"1.3.2","list_caption":"Figure: 将代码复制到不同的文件夹中保存","alt":"将代码复制到不同的文件夹中保存","nro":16,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/2020-11-17/1605571444613-image.png","index":11,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"将代码复制到不同的文件夹中保存","attributes":{},"skip":false,"key":"1.3.2.11"},{"backlink":"./2.2.Terraform基础概念——状态管理.html#fig1.3.2.12","level":"1.3.2","list_caption":"Figure: 重新访问 Consul，目前有一个键","alt":"重新访问 Consul，目前有一个键","nro":17,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/20240225174932.png","index":12,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"重新访问 Consul，目前有一个键","attributes":{},"skip":false,"key":"1.3.2.12"},{"backlink":"./2.2.Terraform基础概念——状态管理.html#fig1.3.2.13","level":"1.3.2","list_caption":"Figure: Consul 中多了一个 `localstack-aws-env:feature1`","alt":"Consul 中多了一个 `localstack-aws-env:feature1`","nro":18,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/20240225175538.png","index":13,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"Consul 中多了一个 `localstack-aws-env:feature1`","attributes":{},"skip":false,"key":"1.3.2.13"},{"backlink":"./2.2.Terraform基础概念——状态管理.html#fig1.3.2.14","level":"1.3.2","list_caption":"Figure: 此时 `localstack-aws-env:feature1` 的内容","alt":"此时 `localstack-aws-env:feature1` 的内容","nro":19,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/20240225175806.png","index":14,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"此时 `localstack-aws-env:feature1` 的内容","attributes":{},"skip":false,"key":"1.3.2.14"},{"backlink":"./2.2.Terraform基础概念——状态管理.html#fig1.3.2.15","level":"1.3.2","list_caption":"Figure: `localstack-aws-env:feature1` 被删除了","alt":"`localstack-aws-env:feature1` 被删除了","nro":20,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/20240225180126.png","index":15,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"`localstack-aws-env:feature1` 被删除了","attributes":{},"skip":false,"key":"1.3.2.15"},{"backlink":"./5.10.graph.html#fig1.6.10.1","level":"1.6.10","list_caption":"Figure: 生成的依赖图","alt":"生成的依赖图","nro":21,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/2020-11-25/1606272727693-image.png","index":1,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"生成的依赖图","attributes":{},"skip":false,"key":"1.6.10.1"},{"backlink":"8.CloudPosse最佳实践.html#fig1.9.1","level":"1.9","list_caption":"Figure: Terraform 输出值的命名要对称","alt":"Terraform 输出值的命名要对称","nro":22,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/2021-11-28/1638086002974-image.png","index":1,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"Terraform 输出值的命名要对称","attributes":{},"skip":false,"key":"1.9.1"}]},"title":"《Terraform入门教程》","gitbook":"*"},"file":{"path":"3.3.输入变量.md","mtime":"2024-05-25T00:11:31.202Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2024-06-24T12:39:39.308Z"},"basePath":".","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="gitbook/gitbook.js"></script>
    <script src="gitbook/theme.js"></script>
    
        
        <script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    

    </body>
</html>

